package iconSwingStates.Transitions;

import iconSwingStates.Event.EVirtualConPositionEvent;
import iconSwingStates.StateMachine.SMIconStateMachine;


/**
 * TPosition is an extending class of TTransition. It manages a standard transition plus position datas 
 * @author uribe-gaget
 */
public class TPosition extends TGeneric{
	private String name;
	private String pointer;


	/**
	 * Constructor without any slots except the default ANY one.
	 * @param name Name of the transition
	 * @param pointer Name of the pointer
	 * @param obligatory True if the slot must be connected
	 */
	public TPosition(String name, String pointer, boolean obligatory) {
		super(name,SMIconStateMachine.ANY, obligatory,false);
		this.name = name;
		this.pointer = pointer;
	}
	
	/**
	 * Constructor without any slots.
	 * @param name Name of the transition
	 * @param pointer Name of the pointer
	 */
	public TPosition(String name, String pointer) {
		super(name);
		this.name = name;
		this.pointer = pointer;
	}
	
	/**
	 * Constructor without any slots.
	 * @param name Name of the transition
	 * @param pointer Name of the pointer
	 * @param outputState The output state
	 */
	public TPosition(String name,  String pointer,String outputState) {
		super(name,outputState);
		this.name = name;
		this.pointer = pointer;
	}


	/**
	 * Constructor with one slot.
	 * @param name Name of the transition
	 * @param pointer Name of the pointer
	 * @param type The slot's type
	 * @param obligatory True if the slot must be connected
	 */
	public TPosition(String name, String pointer,int type, boolean obligatory) {
		super(name,type, obligatory,false);
		this.name = name;
		this.pointer = pointer;
	}
	/**
	 * Constructor without any slots except the default ANY one.
	 * @param name Name of the transition
	 * @param pointer Name of the pointer
	 * @param obligatory True if the slot must be connected
	 * @param output The output state
	 */
	public TPosition(String name, String pointer,boolean obligatory, String output) {
		super(name,SMIconStateMachine.ANY,obligatory,false,output);
		this.name = name;
		this.pointer = pointer;
	}

	/**
	 * Constructor with one slot.
	 * @param name Name of the transition
	 * @param pointer Name of the pointer
	 * @param type The slot's type
	 * @param obligatory True if the slot must be connected
	 * @param output The output state
	 */
	public TPosition(String name, String pointer,int type,boolean obligatory, String output) {
		super(name,type,obligatory,false,output);
		this.name = name;
		this.pointer = pointer;
	}

	/**
	 * Constructor with more than one slot.
	 * @param name Name of the transition
	 * @param pointer Name of the pointer
	 * @param type The slots' types
	 * @param obligatory True if the slot must be connected
	 * @param synchro True if the slots must have a synchronized activity
	 */
	public TPosition(String name, String pointer,int[] type, boolean obligatory,boolean synchro) {
		super(name,type, obligatory,synchro);
		this.name = name;
		this.pointer = pointer;
	}

	/**
	 * Constructor with more than one slot.
	 * @param name Name of the transition
	 * @param pointer Name of the pointer
	 * @param type The slots' types
	 * @param obligatory True if the slot must be connected
	 * @param synchro True if the slots must have a synchronized activity
	 * @param ouput The output state
	 */
	public TPosition(String name, String pointer,int[] type,boolean obligatory,boolean synchro, String output) {
		super(name,type,obligatory,synchro,output);
		this.name = name;
		this.pointer = pointer;
	}

	/**
	 * Returns the name
	 * @return the transition name
	 */
	public String getName(){
		return name;
	}
	
	/**
	 * Returns the pointer
	 * @return the pointer
	 */
	public String getPointer(){
		return pointer;
	}

	/**
	 * Cf méthode matches de VirtualEvent
	 * @param eventObject
	 * @return
	 */
	 public boolean matches(EVirtualConPositionEvent eventObject) {
		if(classEvent != null) {
			return classEvent.isAssignableFrom(EVirtualConPositionEvent.class);
		} else {
			if (eventObject instanceof EVirtualConPositionEvent) {
				String event = ((EVirtualConPositionEvent) eventObject).getNameEvent();
				return (event == null && name == null);
			}
		}
		return false;
	}

	@Override
	public EVirtualConPositionEvent getEvent() {
		return (EVirtualConPositionEvent)super.getEvent();
	}

}